package com.eden.door.component;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.PrinterException;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import javax.swing.JTable;

import com.eden.door.context.AppContext;
import com.eden.door.view.About;
import com.eden.door.view.Help;

public class PopupMenu extends JPopupMenu {

	/**
	 * Create the panel.
	 */
	public PopupMenu() {
		
		JMenuItem setup = new JMenuItem("系统设置");
		setup.setPreferredSize(new Dimension(135, 30));
		add(setup);
		
		JSeparator separator = new JSeparator();
		add(separator);
		
		JMenuItem print = new JMenuItem("打印");
		print.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JTable table = AppContext.instance().getCurrDoorView().getTable() ;
				if(table == null) {
					return ;
				}
				try {
					table.print() ;
				} catch (PrinterException e1) {
					e1.printStackTrace();
				}
			}
		});
		print.setPreferredSize(new Dimension(135, 30));
		add(print);
		
		JSeparator separator_1 = new JSeparator();
		add(separator_1);
		
		JMenuItem mntmNewMenuItem_3 = new JMenuItem("帮助");
		mntmNewMenuItem_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new Help().setVisible(true) ;
			}
		});
		mntmNewMenuItem_3.setPreferredSize(new Dimension(67, 30));
		add(mntmNewMenuItem_3);
		
		JMenuItem mntmNewMenuItem_2 = new JMenuItem("关于");
		mntmNewMenuItem_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new About().setVisible(true) ;
			}
		});
		mntmNewMenuItem_2.setPreferredSize(new Dimension(135, 30));
		add(mntmNewMenuItem_2);
		
		JMenuItem mntmNewMenuItem_4 = new JMenuItem("");
		add(mntmNewMenuItem_4);

	}

}
